import './admin.less';
import React, { Component } from 'react';
import { Layout } from 'antd';
import { BrowserRouter, Redirect, Route, Switch} from 'react-router-dom';
import memoryUtils from '../../utils/memoryUtils';
import storageUtils from '../../utils/storageUtils';
/*
路由配置
*/
import Home from '../home/home'
import Category from '../category/category';
import Product from '../product/product';
import Role from '../role/role';
import User from '../user/user';
import Bar from '../charts/bar';
import Line from '../charts/line';
import Pie from '../charts/pie';

import Header  from '../../components/header';
import LeftNav  from '../../components/left-nav';
const { Footer, Sider, Content } = Layout;



/*
管理的路由组件
*/
export default class Admin extends Component {
    
    render() {
        // const user=storageUtils.getUser()
        const user=localStorage.getItem('username');
        //如果内存中没有user,表示没有登录
        if(!user){
            //自动跳转到登录
            return <Redirect to='/login' />
        }
        return (
            <div className="box">
            <Layout style={{height:'100%'}}>
            <Sider><LeftNav/></Sider>
            <Layout>
            <Header></Header>
            <Content className="content" style={{margin: 20,backgroundColor:'#fff'}}>
            {/* 欢迎你，{user} */}
            <Switch>
            <Route path='/home' component={Home} />
                <Route path='/home' component={Home}></Route>
                <Route path='/category' component={Category}/>
                <Route path='/product' component={Product}/>
                <Route path='/role' component={Role}/>
                <Route path='/user' component={User}/>
                <Route path='/bar' component={Bar}/>
                <Route path='/line' component={Line}/>
                <Route path='/pie' component={Pie}/>
                <Redirect to='home'/>
            </Switch>
            </Content>
            <Footer className="footer" style={{textAlign:'center'}}>欢迎登录RNG后台管理系统</Footer>
            </Layout>
          </Layout>
          </div>
        )
    }
}
